
alter view vi_phones_users_accounts as
SELECT     u.id AS user_id, u.categ_id AS [u.categ_id], u.dt AS [u.dt], u.dt_locked, p.id AS phone_id, p.dt AS [p.dt], p.dt_removed, p.enabled AS [p.enabled], p.phone, 
                      a.id AS account_id, a.dt AS [a.dt], a.enabled AS [a.enabled], a.summary, a.uid, a.dt_last, ac.id AS categ_id, ac.code, ac.currency_code, ac.currency_name, ac.title, 
                      u.name
FROM         dbo.accounts AS a WITH (NOLOCK) INNER JOIN
                      dbo.account_categs AS ac WITH (nolock) ON a.categ_id = ac.id INNER JOIN
                      dbo.users AS u WITH (nolock) ON u.id = a.uid INNER JOIN
                      dbo.phones AS p WITH (nolock) ON p.uid = u.id
go
